package com.jereh.weibo.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;

import com.jereh.weibo.R;
import com.jereh.weibo.adapter.ListAdaprter;
import com.jereh.weibo.entity.List1;
import com.jereh.weibo.manager.ListManager;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/12/2.
 */
public class HomeFragment extends Fragment {

    private Context ctx;
    private ListView listView;
    private View headerView;
    private BaseAdapter adapter;
    private List<List1> list=new ArrayList<>();

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        this.ctx=context;

    }

    @Nullable
    @Override
    public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        final View view=inflater.inflate(R.layout.main_top,null);
        listView=(ListView)view.findViewById(R.id.listview);
        headerView=inflater.inflate(R.layout.main_top_header,null);
        adapter=new ListAdaprter(getActivity(),list);
        listView.addHeaderView(headerView);
        listView.setAdapter(adapter);
        list= ListManager.getListData();
        adapter.notifyDataSetChanged();
        return view;
    }

}
